package com.example.mapper.dao;

import com.example.entity.trace.Trace;
import com.example.entity.trace.dto.LineTraceDTO;
import com.example.entity.trace.dto.QRTraceDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface QRDao {

    @Select("select * from traces where traceUid=#{traceUid}")
    Trace selectTraceByUid(String traceUid);

    @Select("select * from traceTimeLine where traceUid=#{traceUid}")
    Set<LineTraceDTO> selectTraceLineByUid(String traceUid);

    @Insert("insert into traces(traceUid,itemId,qrImg,startDate,lastDate) values(#{traceCode},#{itemId},#{qrImg},DATE_FORMAT(NOW(),'%Y-%m-%d'),DATE_FORMAT(NOW(),'%Y-%m-%d'))")
    int insertTrace(String traceCode,String itemId,String qrImg);

    @Select("select traceUid,qrImg from traces where itemId=#{itemId}")
    QRTraceDTO GetTraceUid(String itemId);
}
